/**
 * 是否所有1都至少相隔K个元素
 *
 * @USER: Administrator
 * @DATE: 2024/9/27 下午10:16
 * @VERSION: 1.0.0
 */
public class LC1437 {
    public static void main(String[] args) {

    }

    public boolean kLengthApart(int[] nums, int k) {
        int apart = 0;
        int first = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 1) {
                first = i;
                break;
            }
        }

        for (int i = first+1; i < nums.length; i++) {
            if (nums[i] == 0) {
                apart++;
            }else {
                if (apart < k) {
                    return false;
                }
                apart=0;
            }
        }
        return true;
    }

}
